package com.lottery.pay.Model.weixin;

import com.lottery.pay.Constants.WeixinConstant;
import org.apache.commons.lang.RandomStringUtils;

public class RefundParam {
	private String appid = "";// 公众账号ID
	private String mch_id = "";// 商户号
	private String device_info = "WEB";// 设备号 PC网页或公众号内支付请传"WEB"
	private String nonce_str = RandomStringUtils.randomAlphanumeric(20);// 生成随机字符串
	private String sign = "";// 签名
	private String out_trade_no = "";// 商户订单号
	private String out_refund_no = "";// 商户退款单号
	private String refund_fee_type = "CNY";// 货币类型 默认人民币：CNY
	private String total_fee = "";// 总金额 单位为分
	private String refund_fee = "";// 退款金额 单位为分
	private String op_user_id = "";// 操作员帐号, 默认为商户号

	public RefundParam(String appid, String mch_id, String out_trade_no, String out_refund_no,
                       String total_fee, String refund_fee) {
		this.appid = appid;
		this.mch_id = mch_id;
		this.out_trade_no = out_trade_no;
		this.out_refund_no = out_refund_no;
		this.total_fee = total_fee;
		this.refund_fee = refund_fee;
		this.op_user_id = mch_id;
	}

	public String getAppid() {
		return appid;
	}

	public String getMch_id() {
		return mch_id;
	}

	public String getDevice_info() {
		return device_info;
	}

	public String getNonce_str() {
		return nonce_str;
	}

	public String getSign() {
		return sign;
	}

	public void setSign(String sign) {
		this.sign = sign;
	}

	public String getOut_trade_no() {
		return out_trade_no;
	}

	public void setOut_trade_no(String out_trade_no) {
		this.out_trade_no = out_trade_no;
	}

	public String getOut_refund_no() {
		return out_refund_no;
	}

	public void setOut_refund_no(String out_refund_no) {
		this.out_refund_no = out_refund_no;
	}

	public String getRefund_fee_type() {
		return refund_fee_type;
	}

	public String getTotal_fee() {
		return total_fee;
	}

	public void setTotal_fee(String total_fee) {
		this.total_fee = total_fee;
	}

	public String getRefund_fee() {
		return refund_fee;
	}

	public void setRefund_fee(String refund_fee) {
		this.refund_fee = refund_fee;
	}

	public String getOp_user_id() {
		return op_user_id;
	}

	/**
	 * 转化成指定xml格式
	 */
	public String toXmlString(RefundParam refundParam) {
		String xmlString = String.format(WeixinConstant.REFUND_MSG,
				refundParam.appid, refundParam.mch_id, refundParam.device_info,
				refundParam.nonce_str, refundParam.sign,
				refundParam.out_trade_no, refundParam.out_refund_no,
				refundParam.refund_fee_type, refundParam.total_fee,
				refundParam.refund_fee, refundParam.op_user_id);
		return xmlString;
	}
}
